package com.fs.sys.entityservice.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fs.common.base.service.AbstractBaseEntityService;
import com.fs.sys.bean.dto.TenantDTO;
import com.fs.sys.bean.query.TenantQuery;
import com.fs.sys.domain.entity.TenantEntity;
import com.fs.sys.domain.mapper.TenantMapper;
import com.fs.sys.entityservice.TenantEntityService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 租户服务实现 
 * @author Coder Generator 2025-06-13 18:13:50 
 **/
@Service
public class TenantEntityServiceImpl extends AbstractBaseEntityService<TenantEntity, TenantDTO, TenantMapper, TenantQuery> implements TenantEntityService {
    @Override
    protected QueryWrapper<TenantEntity> queryToWrapper(TenantQuery query) {
        return this.createQueryWrapper()
                .eq(StringUtils.isNotBlank(query.getId()), "id", query.getId())
                .in(null != query.getIds(), "id", query.getIds())
                .eq(StringUtils.isNotBlank(query.getName()), "name", query.getName())
                .like(StringUtils.isNotBlank(query.getNameLike()), "name", query.getNameLike())
                .eq(StringUtils.isNotBlank(query.getIdCard()), "id_card", query.getIdCard())
                .orderByDesc("create_time");
    }

    /**
     * 如果在在租户编号时，是否需要根据租户编号进行筛选
     *
     * @return 是否根据租户编号筛选数据
     */
    @Override
    protected boolean filterByTenant() {
        return false;
    }
}